/**
 * 
 */
package com.antilia.infomaresme.pages.signin;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.form.Form;

import com.antilia.infomaresme.pages.ContextPanel;
import com.antilia.infomaresme.pages.register.RegisterPanel;
import com.antilia.infomaresme.pages.register.RegisterSucessPanel;

/**
 * @author Ernesto
 *
 */
public abstract class LogInContextPanel extends ContextPanel {

	private static final long serialVersionUID = 1L;

	/**
	 * @param id
	 */
	public LogInContextPanel(String id) {
		super(id);
		setContents(new LogInPanel(ContextPanel.CONTENT_ID) {
			
			private static final long serialVersionUID = 1L;

			@Override
			public void onLogIn(AjaxRequestTarget target) {									
				LogInContextPanel.this.onLogIn(target);
			}
			
			@Override
			public void onRegister(AjaxRequestTarget target) {
				RegisterPanel registerPanel = new RegisterPanel(ContextPanel.CONTENT_ID) {
					
					private static final long serialVersionUID = 1L;

					@Override
					protected void onRegisterSuccess(AjaxRequestTarget target,
							Form<?> form) {
						RegisterSucessPanel registerSucessPanel = new RegisterSucessPanel(ContextPanel.CONTENT_ID);
						setContents(registerSucessPanel);
						target.add(LogInContextPanel.this);
					}
				};
				setContents(registerPanel);
				target.add(LogInContextPanel.this);
			}
		});
	}
	
	public abstract void onLogIn(AjaxRequestTarget target);
	

}
